package com.eben.model;


import android.graphics.Canvas;
import android.graphics.Color;

public class BadObject extends GameObject{
	
	private int damage;
	
	/**
	 * Creates a fully customizable BadObject
	 * @param velocity the speed of the BadObject (Pixels per second)
	 * @param direction the direction which the BadObject moves
	 * @param position the starting position of the BadObject
	 * @param radius the radius of the BadObject
	 * @param color the color of the BadObject
	 * @param damage the damage which the BadObject inflicts
	 */
	public BadObject(double velocity, double direction, Position position, int radius, int color, int damage){
		super(velocity, direction, position, radius, color);
		this.damage = damage;
		paint.setColor(color);
	}
	
	/**
	 * Creates a new BadObject with random damage and size that matches the damage, at the position (0,0).
	 */
	public BadObject(){
		this(1, 0, new Position(0,0), 10, Color.WHITE, 10);
	}
	
	/**
	 * Creates a new BadObject at the position pos
	 * @param pos the start position of the BadObject
	 */
	public BadObject(double direction, Position pos){
		this(1, direction, pos, 5, Color.WHITE, 10);
	}

	/**
	 * updates the position of the BadObject
	 */
	@Override
	public void updatePosition() {
		position.setX(position.getX() + (Math.cos(direction)*velocity));
		position.setY(position.getY() - (Math.sin(direction)*velocity)); // "-" instead of "+" 
										//because in the gui the y-axel is turned up side down.
	}
	
	/**
	 * Returns damage of the object
	 * @return the damage
	 */
	public int getDamage(){
		return damage;
	}
	
	public void setDamage(int damage){
		this.damage = damage;
	}
	
	public void setColor(int color){
		paint.setColor(color);
	}
	
	@Override
	public void draw(Canvas canvas) {
		canvas.drawCircle((float)position.getX(), (float)position.getY(), radius, paint);
	}

}
